package com.hk.springtrains.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
public class WebSocketHandlerWithSimpTemplate {


    /**
     * 使用SimpMessagingTemplate可以在任意位置发送消息
     */
    @Autowired
    private SimpMessagingTemplate template;


    public void sendMessage(Msg msg){
        template.convertAndSend("/topic/async3",msg);
    }

}
